package com.shcowin.dao.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.shcowin.dao.NewsDao;
import com.shcowin.entity.News;
import com.shcowin.mapper.NewsMapper;

/**
 * function: Account��ݿ����dao
 * 
 * @author hoojo
 * @createDate 2011-4-13 ����10:25:02
 * @file AccountDaoImpl.java
 * @package com.hoo.dao.impl
 * @project MyBatisForSpring
 * @blog http://blog.csdn.net/IBM_hoojo
 * @email hoojo_@126.com
 * @version 1.0
 */
@SuppressWarnings("unchecked")
@Repository
public class NewsDaoImpl implements NewsDao {

	@Inject
	private NewsMapper mapper;

	public boolean add(News entity) throws DataAccessException {
		boolean flag = false;
		try {
			mapper.add(entity);
			flag = true;
		} catch (DataAccessException e) {
			flag = false;
			throw e;
		}
		return flag;
	}
	
	public boolean edit(News entity) throws DataAccessException {
		boolean flag = false;
		try {
			mapper.edit(entity);
			flag = true;
		} catch (DataAccessException e) {
			flag = false;
			throw e;
		}
		return flag;
	}

	public News getById(Integer id) throws DataAccessException {
		News entity = null;
		try {
			entity = mapper.getById(id);
		} catch (DataAccessException e) {
			throw e;
		}
		return entity;
	}

	public List<News> getAll() throws DataAccessException {
		return mapper.getAll();
	}

	public void del(int id) throws DataAccessException {
		mapper.del(id);
		
	}

	public List<News> getByPage(int start, int end) throws DataAccessException {
		 
		return mapper.getByPage(start, end);
	}

	public int getCount() throws DataAccessException {
		return mapper.getCount();
	}

	public List<News> getDynamicByPage(int start, int end)
			throws DataAccessException {
		return mapper.getDynamicByPage(start, end);
	}

	public List<News> getNewsByPage(int start, int end)
			throws DataAccessException {
		return mapper.getNewsByPage(start, end);
	}
}